package com.zzvcom.sms;

import com.zzvcom.sms.client.AppClient;
import com.zzvcom.sms.client.DefaultAppClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;

/**
 * 调用 sdk demo
 */
public class Demo {

    private static final Logger LOGGER = LoggerFactory.getLogger(Demo.class);

    private static final String COMPANY_CODE = "YOUR_COMPANY_CODE";
    private static final String APP_KEY = "YOUR_APP_KEY";
    private static final String APP_SECRET = "YOUR_APP_SECRET";


    public static void main(String[] args) {
        AppClient appClient = new DefaultAppClient(COMPANY_CODE, APP_KEY, APP_SECRET);

        String licensePlateNumber = "123456";
        String rfidPlateNumber = "1234567890";
        String vin = "1234567890";
        String rfidNumber = "1234567890";
        BigDecimal longitude = BigDecimal.valueOf(113.546744);
        BigDecimal latitude = BigDecimal.valueOf(34.817232);


        // 锁车--(rfidNumber 非空, 若rfidNumber非空,则参与加密运算)
        String lockResponse1 = appClient.lockMoped(licensePlateNumber, rfidPlateNumber, vin, rfidNumber, longitude, latitude);
        LOGGER.info("锁车上报(rfidNumber 非空)：" + lockResponse1);

        // 锁车--(rfidNumber 为空, 若rfidNumber为空,则不参与加密运算)
        String lockResponse2 = appClient.lockMoped(licensePlateNumber, rfidPlateNumber, vin, null, longitude, latitude);
        LOGGER.info("锁车上报(rfidNumber 为空)：" + lockResponse2);

        // 开锁
        String unlockResponse = appClient.unlockMoped(licensePlateNumber, rfidPlateNumber, vin, longitude, latitude);
        LOGGER.info("开锁上报：" + unlockResponse);

        // 维护
        String maintainResponse = appClient.maintainMoped(licensePlateNumber, rfidPlateNumber, vin);
        LOGGER.info("维护上报：" + maintainResponse);

        // 废弃
        String discardResponse = appClient.discardMoped(licensePlateNumber, rfidPlateNumber, vin);
        LOGGER.info("废弃上报：" + discardResponse);

        // 开始临停
        Integer pauseType = 0;
        String pauseTypeResponse = appClient.mopedPause(licensePlateNumber, rfidPlateNumber, vin, pauseType, longitude, latitude);
        LOGGER.info("主动类型临停：" + pauseTypeResponse);

        Integer staticType = 1;
        String staticTypeResponse = appClient.mopedPause(licensePlateNumber, rfidPlateNumber, vin, staticType, longitude, latitude);
        LOGGER.info("静止类型临停：" + staticTypeResponse);

        // 结束临停
        String resumeResponse1 = appClient.mopedResume(licensePlateNumber, rfidPlateNumber, vin, longitude, latitude);
        LOGGER.info("结束临停：" + resumeResponse1);

        String parkingSyncResponse = appClient.parkingSync(System.currentTimeMillis()/1000, 1);
        LOGGER.info("泊车点同步：" + parkingSyncResponse);
    }
}
